import http from "@/utils/http";

export async function useSceneParse(options) {

    const { query, openType } = {
        openType: 'reLaunch', // navigateTo
        ...options
    }
    const { scene } = query

    // scene限制长度32位，故走接口中获取完整的参数
    if (scene && scene.includes('TOKEN_')) {
        const token = scene.split(`TOKEN_`).pop()

        return http({
            method: 'GET',
            url: `/wechat/mini/scene/info`,
            params: {
                token
            },
            needLogin: false
        }).then(res => {

            if (openType && res.data.isJump) {
                uni[openType]({
                    url: res.data.path,
                })
            }

            return res.data;
        })
    }

}